package com.heima.wemedia.controller.v1;

import com.heima.apis.wemedia.MaterialManageControllerApi;
import com.heima.apis.wemedia.WmMaterialControllerApi;
import com.heima.common.constans.wemedia.WemediaContans;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.media.dto.WmMaterialDto;
import com.heima.wemedia.service.MaterialService;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/material")
public class MaterialManageController implements MaterialManageControllerApi {
    @Autowired
    private MaterialService materialService;
    @Override
    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmMaterialDto dto) {
        return materialService.findList(dto);
    }

    @Override
    @GetMapping("/del_picture/{id}")
    public ResponseResult delPicture(@PathVariable("id") Integer id) {
        return materialService.delPicture(id);
    }

    @Override
    @GetMapping("/cancel_collect/{id}")
    public ResponseResult cancelCollectionMaterial(@PathVariable("id") Integer id) {
        return materialService.updateStatus(id, WemediaContans.CANCEL_COLLECT_MATERIAL);
    }

    @Override
    @GetMapping("/collect/{id}")
    public ResponseResult collectionMaterial(@PathVariable("id") Integer id) {
        return materialService.updateStatus(id,WemediaContans.COLLECT_MATERIAL);
    }
}
